<script setup>
import MyForm from "@/components/MyForm.vue";
import {ref, shallowReactive, shallowRef} from "vue";
import {RULE} from "@/const";
import MyNav from "@/components/MyNav.vue";
import router from "@/router";
import {updateApi} from "@/api/RoomApi";
// 获取房间记录
let room = JSON.parse(sessionStorage.getItem('room'));
console.log(room)

// 表单项
let items = shallowRef([
  {'label': '房间名称', 'prop': 'title'},
  {'label': '房间容量', 'prop': 'capacity', 'type': 'number'},
  {'label': '房间地址', 'prop': 'address', 'type': 'textarea'},
  {'label': '房间描述', 'prop': 'info', 'type': 'textarea'},
]);
// 表单默认值
let data = shallowReactive({
  'id': room['id'],
  'title': room['title'],
  'capacity': room['capacity'],
  'address': room['address'],
  'info': room['info'],
});
// 表单规则
let rules = {
  'info': RULE.COMMON_INFO,
  'title': RULE.COMM_TITLE,
};
</script>

<template>

  <my-nav :items="[
  {'icon': 'User', 'label': '员工管理'},
  {'icon': 'User', 'label': '房间列表', 'url': '/rms/Room'},
  {'icon': 'User', 'label': '修改房间'},
]"/>

  <el-divider/>
  <my-form type="update"
           :items="items"
           :data="data"
           :rules="rules"
           :api="updateApi"
           :fn="() => router.push('/rms/Room')"
           :span="2"/>

</template>

<style scoped lang="scss">

</style>